package com.example.XueCuApp.Customer;

import android.content.Context;
import android.content.res.TypedArray;

import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;


import com.example.XueCuApp.R;


public class InputInformation extends LinearLayout {
    private TextView inputTitle;
    private TextView inputText;
    private ImageView imageView;

    public InputInformation(Context context) {
        this(context, null);
    }

    public InputInformation(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public InputInformation(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context, attrs);
    }

    private void initView(Context context, AttributeSet attrs) {

        LayoutInflater.from(context).inflate(R.layout.input_information, this, true);
        inputTitle = (TextView) findViewById(R.id.tv_input_title);
        inputText = (TextView) findViewById(R.id.et_input_text);
        imageView = (ImageView) findViewById(R.id.iv_input_image);

        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.InputInformation);

        if (typedArray != null) {
            String title = typedArray.getString(R.styleable.InputInformation_input_title);
            inputTitle.setText(title);

            String text = typedArray.getString(R.styleable.InputInformation_input_text);
            inputText.setText(text);

            boolean isShow = typedArray.getBoolean(R.styleable.InputInformation_is_show, true);
            if (isShow) {
                imageView.setVisibility(VISIBLE);
            } else {
                imageView.setVisibility(GONE);
            }

        }
        typedArray.recycle();
    }

    public String getEditName() {
        return inputText.getText().toString().trim();
    }

    public void setEditName(String ss) {
        inputText.setText(ss);
    }
}
